package components;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JMenuBar;

import fr.inria.insitu.noe.Platform;
import fr.inria.insitu.noe.exp.model.Intertitle;
import fr.lri.swingstates.canvas.Canvas;

/**
 * Used to install experiment framework.
 * 
 * @touchstone.measure ExecutionTime 
 *  name: "Execution time"
 *  help: "Duration of the selection gesture(s)" 
 *  type: ratio
 *  
 *  @touchstone.measure ReactionTime 
 *  name: "Reaction time"
 *  help: "Time between the display of the instructions and the start of the stroke" 
 *  type: ratio
 *  
 *  @touchstone.measure OrientationError
 *  name: "Orientation error"
 *  help: "Orientation errors, i.e. when gestures don't fit with the specified direction. Applies to every menu." 
 *  type: integer
 *  
 *  @touchstone.measure ShapeError
 *  name: "Shape error"
 *  help: "Shape errors, i.e. when gestures aren't rectilinear. Applies to all menus except Flower Menu." 
 *  type: integer
 *  
 *  @touchstone.measure LengthError
 *  name: "Length error"
 *  help: "Length errors, i.e. when gestures doesn't have the right length. Applies to DEMM." 
 *  type: integer
 *  
 *  @touchstone.measure PositionError
 *  name: "Position errors"
 *  help: "Position errors, i.e. when the stroke doesn't start from the right zone. Applies to Zone Menu." 
 *  type: integer
 *  
 *  ============================================================================================================
 *  
 *  @touchstone.measure Mouse.x
 *  name: "Stroke dots X coordinates"
 *  help: "Used to keep the trajectory of the cursor for further analysis" 
 *  type: ratio
 *  
 *  @touchstone.measure Mouse.y
 *  name: "Stroke dots Y coordinates"
 *  help: "Used to keep the trajectory of the cursor for further analysis" 
 *  type: ratio
 * 
 * @touchstone.intertitle SetupExperiment
 */
public class SetupExperiment extends Intertitle {

	public static final String START_BUTTON = "Start Button";
	
	private JFrame mainFrame;
	private Canvas gestureArea;
	
	public SetupExperiment() {
		
	}
	
	@Override
	public void beginIntertitle() {
		
		mainFrame = new JFrame("Experiment");
		
		JMenuBar menuBar = new JMenuBar();
		menuBar.setVisible(false);
		mainFrame.setJMenuBar(menuBar);
		
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		
//		mainFrame.setUndecorated(true);
//		GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(mainFrame);
		
		// mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
		
		gestureArea = new Canvas((int)screenSize.getWidth(), (int)screenSize.getHeight());
		gestureArea.setBackground(new Color(240,240, 240));
		
		System.out.println("=============\n" + Math.sqrt(screenSize.getWidth() * screenSize.getWidth() + screenSize.getHeight() * screenSize.getHeight())/2);

		mainFrame.getContentPane().add(gestureArea);
		
		mainFrame.pack();
		mainFrame.setVisible(true);
		mainFrame.requestFocus();
	}

	public JFrame getMainFrame() {
		return mainFrame;
	}

	public Canvas getGestureArea() {
		return gestureArea;
	}
}
